<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.9.1"/>
<title>knet: 广播</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { init_search(); });
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <div id="projectname">knet
   &#160;<span id="projectnumber">1.4.3</span>
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- 制作者 Doxygen 1.8.9.1 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'搜索');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>首页</span></a></li>
      <li><a href="modules.html"><span>模块</span></a></li>
      <li><a href="annotated.html"><span>类</span></a></li>
      <li><a href="files.html"><span>文件</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="搜索" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
</div><!-- top -->
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="summary">
<a href="#func-members">函数</a>  </div>
  <div class="headertitle">
<div class="title">广播</div>  </div>
</div><!--header-->
<div class="contents">
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
函数</h2></td></tr>
<tr class="memitem:gaa3b09fb6ff3281cb10736c0aabac18fc"><td class="memItemLeft" align="right" valign="top"><a class="el" href="struct__broadcast__t.html">broadcast_t</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__broadcast.html#gaa3b09fb6ff3281cb10736c0aabac18fc">broadcast_create</a> ()</td></tr>
<tr class="separator:gaa3b09fb6ff3281cb10736c0aabac18fc"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaa28451fa4656633ded0c7b966ff159c3"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__broadcast.html#gaa28451fa4656633ded0c7b966ff159c3">broadcast_destroy</a> (<a class="el" href="struct__broadcast__t.html">broadcast_t</a> *broadcast)</td></tr>
<tr class="separator:gaa28451fa4656633ded0c7b966ff159c3"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga1c736809a1d0e4b7c77b617ac8ce590d"><td class="memItemLeft" align="right" valign="top"><a class="el" href="struct__channel__ref__t.html">channel_ref_t</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__broadcast.html#ga1c736809a1d0e4b7c77b617ac8ce590d">broadcast_join</a> (<a class="el" href="struct__broadcast__t.html">broadcast_t</a> *broadcast, <a class="el" href="struct__channel__ref__t.html">channel_ref_t</a> *channel_ref)</td></tr>
<tr class="separator:ga1c736809a1d0e4b7c77b617ac8ce590d"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gad846ced37d33b750f61a88565eaed9a4"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__broadcast.html#gad846ced37d33b750f61a88565eaed9a4">broadcast_leave</a> (<a class="el" href="struct__broadcast__t.html">broadcast_t</a> *broadcast, <a class="el" href="struct__channel__ref__t.html">channel_ref_t</a> *channel_ref)</td></tr>
<tr class="separator:gad846ced37d33b750f61a88565eaed9a4"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gacd045b1ca8be7fa8fac6e337934acc97"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__broadcast.html#gacd045b1ca8be7fa8fac6e337934acc97">broadcast_get_count</a> (<a class="el" href="struct__broadcast__t.html">broadcast_t</a> *broadcast)</td></tr>
<tr class="separator:gacd045b1ca8be7fa8fac6e337934acc97"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga0e8a8826a84c9c93a96e0fda1ca846aa"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__broadcast.html#ga0e8a8826a84c9c93a96e0fda1ca846aa">broadcast_write</a> (<a class="el" href="struct__broadcast__t.html">broadcast_t</a> *broadcast, char *buffer, uint32_t size)</td></tr>
<tr class="separator:ga0e8a8826a84c9c93a96e0fda1ca846aa"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">详细描述</h2>
<p>广播域</p>
<pre>
管道可以加入广播域，加入后通过broadcast_write方法可以发送数据到所有已经加入域内的管道.
调用broadcast_create创建一个广播域，broadcast_destroy销毁广播域，broadcast_join
加入一个广播域，broadcast_join函数返回时创建了一个新的管道引用，调用broadcast_leave
时应该使用这个返回值而不是使用broadcast_join的第二个参数，新创建的管道引用会提升管道的
引用计数，如果你关闭了这个管道你可以通过调用broadcast_leave减少管道的引用计数，从而可以
让loop_t真正销毁管道，或者在调用broadcast_write时自动销毁.调用broadcast_get_count
可以得知广播域内的管道引用数量，调用broadcast_write发起一个广播操作，所有域内管道都会收
到你广播的数据.
</pre> <h2 class="groupheader">函数说明</h2>
<a class="anchor" id="gaa3b09fb6ff3281cb10736c0aabac18fc"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="struct__broadcast__t.html">broadcast_t</a>* broadcast_create </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>创建广播域 </p><dl class="section return"><dt>返回</dt><dd>broadcast_t实例 </dd></dl>

</div>
</div>
<a class="anchor" id="gaa28451fa4656633ded0c7b966ff159c3"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void broadcast_destroy </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="struct__broadcast__t.html">broadcast_t</a> *&#160;</td>
          <td class="paramname"><em>broadcast</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>销毁广播域</p>
<p>销毁的同时会将所有还在域内的管道引用销毁 </p><dl class="params"><dt>参数</dt><dd>
  <table class="params">
    <tr><td class="paramname">broadcast</td><td>broadcast_t实例 </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="gacd045b1ca8be7fa8fac6e337934acc97"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int broadcast_get_count </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="struct__broadcast__t.html">broadcast_t</a> *&#160;</td>
          <td class="paramname"><em>broadcast</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>取得广播域内管道数量 </p><dl class="params"><dt>参数</dt><dd>
  <table class="params">
    <tr><td class="paramname">broadcast</td><td>broadcast_t实例 </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>返回</dt><dd>管道数量 </dd></dl>

</div>
</div>
<a class="anchor" id="ga1c736809a1d0e4b7c77b617ac8ce590d"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="struct__channel__ref__t.html">channel_ref_t</a>* broadcast_join </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="struct__broadcast__t.html">broadcast_t</a> *&#160;</td>
          <td class="paramname"><em>broadcast</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="struct__channel__ref__t.html">channel_ref_t</a> *&#160;</td>
          <td class="paramname"><em>channel_ref</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>加入广播域</p>
<p>加入成功会生成一个新的引用 </p><dl class="params"><dt>参数</dt><dd>
  <table class="params">
    <tr><td class="paramname">broadcast</td><td>broadcast_t实例 </td></tr>
    <tr><td class="paramname">channel_ref</td><td>channel_ref_t </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>返回</dt><dd>channel_ref_t实例，新的在广播域内的引用 </dd></dl>

</div>
</div>
<a class="anchor" id="gad846ced37d33b750f61a88565eaed9a4"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int broadcast_leave </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="struct__broadcast__t.html">broadcast_t</a> *&#160;</td>
          <td class="paramname"><em>broadcast</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="struct__channel__ref__t.html">channel_ref_t</a> *&#160;</td>
          <td class="paramname"><em>channel_ref</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>离开广播域</p>
<p>函数返回后管道引用已经被销毁，不要尝试再次访问这个引用 </p><dl class="params"><dt>参数</dt><dd>
  <table class="params">
    <tr><td class="paramname">broadcast</td><td>broadcast_t实例 </td></tr>
    <tr><td class="paramname">channel_ref</td><td>channel_ref_t实例，由broadcast_join()返回 </td></tr>
  </table>
  </dd>
</dl>
<dl class="retval"><dt>返回值</dt><dd>
  <table class="retval">
    <tr><td class="paramname">error_ok</td><td>成功 </td></tr>
    <tr><td class="paramname">其他</td><td>失败 </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="ga0e8a8826a84c9c93a96e0fda1ca846aa"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int broadcast_write </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="struct__broadcast__t.html">broadcast_t</a> *&#160;</td>
          <td class="paramname"><em>broadcast</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">char *&#160;</td>
          <td class="paramname"><em>buffer</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint32_t&#160;</td>
          <td class="paramname"><em>size</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>广播</p>
<p>所有已经被关闭的管道在本函数调用时会被自动销毁 </p><dl class="params"><dt>参数</dt><dd>
  <table class="params">
    <tr><td class="paramname">broadcast</td><td>broadcast_t实例 </td></tr>
    <tr><td class="paramname">buffer</td><td>缓冲区指针 </td></tr>
    <tr><td class="paramname">size</td><td>缓冲区长度 </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>返回</dt><dd>发送成功管道的数量 </dd></dl>

</div>
</div>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
生成于 2015年 七月 9日 星期四 14:59:53 , 为 knet使用  &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.9.1
</small></address>
</body>
</html>
